{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "<CENTER><img src=\"http://opendata.atlas.cern/DataAndTools/pictures/ATLASOD.gif\" style=\"width:50%\"></CENTER>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<CENTER><h1>Get running the analysis of Hyy channel using the 13 TeV dataset in C++</h1></CENTER>\n",
    "\n",
    "\n",
    "**Introduction**\n",
    "Let's take a current ATLAS Open Data sample and create histograms:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Import necessary modules that provide a way of using operating system dependent functionality. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#include <stdio.h>\n",
    "#include <stdlib.h>\n",
    "#include <cstdio>\n",
    "#include <iostream>\n",
    "#include <time.h> "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Print current system time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Aug 12 20:06:16 CEST 2019\r\n"
     ]
    }
   ],
   "source": [
    "system(\"date\"); \n",
    "clock_t startTime = clock(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Get Hyy analysis code of 13Tev dataset  \n",
    "Create a new folder \"cpp-13tev\" in which you place your data and code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "system(\"mkdir cpp-13tev\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List the files in your directory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 100K\r\n",
      "-rw-r--r-- 1 summerstudent users  125 Jul 22 11:07 README.md\r\n",
      "-rw------- 1 summerstudent users 9.6K Jul 22 11:26 get-running-8-tev-code-cpp.ipynb\r\n",
      "-rw-r--r-- 1 summerstudent users  18K Jul 31 20:36 get-running-8-tev-code-python.ipynb\r\n",
      "drwxr-xr-x 2 summerstudent users 4.0K Jul 31 22:37 images\r\n",
      "-rw-r--r-- 1 summerstudent users  14K Aug 12 18:24 get-running-13-tev-python-code.ipynb\r\n",
      "-rw-r--r-- 1 summerstudent users  39K Aug 12 20:05 get-running-13-tev-cpp-code.ipynb\r\n",
      "drwxr-xr-x 2 summerstudent users 4.0K Aug 12 20:06 cpp-13tev\r\n"
     ]
    }
   ],
   "source": [
    "system(\"ls -lhrt\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print your current path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Change current directory to \"cpp-8tev\" "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "chdir(\"cpp-13tev\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print your current path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print current system time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Aug 12 20:06:16 CEST 2019\r\n"
     ]
    }
   ],
   "source": [
    "system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Clone the analysis code from github"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Cloning into 'atlas-outreach-cpp-framework-13tev'...\r\n",
      "remote: Enumerating objects: 336, done.\u001b[K\r\n",
      "remote: Counting objects:   0% (1/336)   \u001b[K\r",
      "remote: Counting objects:   1% (4/336)   \u001b[K\r",
      "remote: Counting objects:   2% (7/336)   \u001b[K\r",
      "remote: Counting objects:   3% (11/336)   \u001b[K\r",
      "remote: Counting objects:   4% (14/336)   \u001b[K\r",
      "remote: Counting objects:   5% (17/336)   \u001b[K\r",
      "remote: Counting objects:   6% (21/336)   \u001b[K\r",
      "remote: Counting objects:   7% (24/336)   \u001b[K\r",
      "remote: Counting objects:   8% (27/336)   \u001b[K\r",
      "remote: Counting objects:   9% (31/336)   \u001b[K\r",
      "remote: Counting objects:  10% (34/336)   \u001b[K\r",
      "remote: Counting objects:  11% (37/336)   \u001b[K\r",
      "remote: Counting objects:  12% (41/336)   \u001b[K\r",
      "remote: Counting objects:  13% (44/336)   \u001b[K\r",
      "remote: Counting objects:  14% (48/336)   \u001b[K\r",
      "remote: Counting objects:  15% (51/336)   \u001b[K\r",
      "remote: Counting objects:  16% (54/336)   \u001b[K\r",
      "remote: Counting objects:  17% (58/336)   \u001b[K\r",
      "remote: Counting objects:  18% (61/336)   \u001b[K\r",
      "remote: Counting objects:  19% (64/336)   \u001b[K\r",
      "remote: Counting objects:  20% (68/336)   \u001b[K\r",
      "remote: Counting objects:  21% (71/336)   \u001b[K\r",
      "remote: Counting objects:  22% (74/336)   \u001b[K\r",
      "remote: Counting objects:  23% (78/336)   \u001b[K\r",
      "remote: Counting objects:  24% (81/336)   \u001b[K\r",
      "remote: Counting objects:  25% (84/336)   \u001b[K\r",
      "remote: Counting objects:  26% (88/336)   \u001b[K\r",
      "remote: Counting objects:  27% (91/336)   \u001b[K\r",
      "remote: Counting objects:  28% (95/336)   \u001b[K\r",
      "remote: Counting objects:  29% (98/336)   \u001b[K\r",
      "remote: Counting objects:  30% (101/336)   \u001b[K\r",
      "remote: Counting objects:  31% (105/336)   \u001b[K\r",
      "remote: Counting objects:  32% (108/336)   \u001b[K\r",
      "remote: Counting objects:  33% (111/336)   \u001b[K\r",
      "remote: Counting objects:  34% (115/336)   \u001b[K\r",
      "remote: Counting objects:  35% (118/336)   \u001b[K\r",
      "remote: Counting objects:  36% (121/336)   \u001b[K\r",
      "remote: Counting objects:  37% (125/336)   \u001b[K\r",
      "remote: Counting objects:  38% (128/336)   \u001b[K\r",
      "remote: Counting objects:  39% (132/336)   \u001b[K\r",
      "remote: Counting objects:  40% (135/336)   \u001b[K\r",
      "remote: Counting objects:  41% (138/336)   \u001b[K\r",
      "remote: Counting objects:  42% (142/336)   \u001b[K\r",
      "remote: Counting objects:  43% (145/336)   \u001b[K\r",
      "remote: Counting objects:  44% (148/336)   \u001b[K\r",
      "remote: Counting objects:  45% (152/336)   \u001b[K\r",
      "remote: Counting objects:  46% (155/336)   \u001b[K\r",
      "remote: Counting objects:  47% (158/336)   \u001b[K\r",
      "remote: Counting objects:  48% (162/336)   \u001b[K\r",
      "remote: Counting objects:  49% (165/336)   \u001b[K\r",
      "remote: Counting objects:  50% (168/336)   \u001b[K\r",
      "remote: Counting objects:  51% (172/336)   \u001b[K\r",
      "remote: Counting objects:  52% (175/336)   \u001b[K\r",
      "remote: Counting objects:  53% (179/336)   \u001b[K\r",
      "remote: Counting objects:  54% (182/336)   \u001b[K\r",
      "remote: Counting objects:  55% (185/336)   \u001b[K\r",
      "remote: Counting objects:  56% (189/336)   \u001b[K\r",
      "remote: Counting objects:  57% (192/336)   \u001b[K\r",
      "remote: Counting objects:  58% (195/336)   \u001b[K\r",
      "remote: Counting objects:  59% (199/336)   \u001b[K\r",
      "remote: Counting objects:  60% (202/336)   \u001b[K\r",
      "remote: Counting objects:  61% (205/336)   \u001b[K\r",
      "remote: Counting objects:  62% (209/336)   \u001b[K\r",
      "remote: Counting objects:  63% (212/336)   \u001b[K\r",
      "remote: Counting objects:  64% (216/336)   \u001b[K\r",
      "remote: Counting objects:  65% (219/336)   \u001b[K\r",
      "remote: Counting objects:  66% (222/336)   \u001b[K\r",
      "remote: Counting objects:  67% (226/336)   \u001b[K\r",
      "remote: Counting objects:  68% (229/336)   \u001b[K\r",
      "remote: Counting objects:  69% (232/336)   \u001b[K\r",
      "remote: Counting objects:  70% (236/336)   \u001b[K\r",
      "remote: Counting objects:  71% (239/336)   \u001b[K\r",
      "remote: Counting objects:  72% (242/336)   \u001b[K\r",
      "remote: Counting objects:  73% (246/336)   \u001b[K\r",
      "remote: Counting objects:  74% (249/336)   \u001b[K\r",
      "remote: Counting objects:  75% (252/336)   \u001b[K\r",
      "remote: Counting objects:  76% (256/336)   \u001b[K\r",
      "remote: Counting objects:  77% (259/336)   \u001b[K\r",
      "remote: Counting objects:  78% (263/336)   \u001b[K\r",
      "remote: Counting objects:  79% (266/336)   \u001b[K\r",
      "remote: Counting objects:  80% (269/336)   \u001b[K\r",
      "remote: Counting objects:  81% (273/336)   \u001b[K\r",
      "remote: Counting objects:  82% (276/336)   \u001b[K\r",
      "remote: Counting objects:  83% (279/336)   \u001b[K\r",
      "remote: Counting objects:  84% (283/336)   \u001b[K\r",
      "remote: Counting objects:  85% (286/336)   \u001b[K\r",
      "remote: Counting objects:  86% (289/336)   \u001b[K\r",
      "remote: Counting objects:  87% (293/336)   \u001b[K\r",
      "remote: Counting objects:  88% (296/336)   \u001b[K\r",
      "remote: Counting objects:  89% (300/336)   \u001b[K\r",
      "remote: Counting objects:  90% (303/336)   \u001b[K\r",
      "remote: Counting objects:  91% (306/336)   \u001b[K\r",
      "remote: Counting objects:  92% (310/336)   \u001b[K\r",
      "remote: Counting objects:  93% (313/336)   \u001b[K\r",
      "remote: Counting objects:  94% (316/336)   \u001b[K\r",
      "remote: Counting objects:  95% (320/336)   \u001b[K\r",
      "remote: Counting objects:  96% (323/336)   \u001b[K\r",
      "remote: Counting objects:  97% (326/336)   \u001b[K\r",
      "remote: Counting objects:  98% (330/336)   \u001b[K\r",
      "remote: Counting objects:  99% (333/336)   \u001b[K\r",
      "remote: Counting objects: 100% (336/336)   \u001b[K\r",
      "remote: Counting objects: 100% (336/336), done.\u001b[K\r\n",
      "remote: Compressing objects:   0% (1/164)   \u001b[K\r",
      "remote: Compressing objects:   1% (2/164)   \u001b[K\r",
      "remote: Compressing objects:   2% (4/164)   \u001b[K\r",
      "remote: Compressing objects:   3% (5/164)   \u001b[K\r",
      "remote: Compressing objects:   4% (7/164)   \u001b[K\r",
      "remote: Compressing objects:   5% (9/164)   \u001b[K\r",
      "remote: Compressing objects:   6% (10/164)   \u001b[K\r",
      "remote: Compressing objects:   7% (12/164)   \u001b[K\r",
      "remote: Compressing objects:   8% (14/164)   \u001b[K\r",
      "remote: Compressing objects:   9% (15/164)   \u001b[K\r",
      "remote: Compressing objects:  10% (17/164)   \u001b[K\r",
      "remote: Compressing objects:  11% (19/164)   \u001b[K\r",
      "remote: Compressing objects:  12% (20/164)   \u001b[K\r",
      "remote: Compressing objects:  13% (22/164)   \u001b[K\r",
      "remote: Compressing objects:  14% (23/164)   \u001b[K\r",
      "remote: Compressing objects:  15% (25/164)   \u001b[K\r",
      "remote: Compressing objects:  16% (27/164)   \u001b[K\r",
      "remote: Compressing objects:  17% (28/164)   \u001b[K\r",
      "remote: Compressing objects:  18% (30/164)   \u001b[K\r",
      "remote: Compressing objects:  19% (32/164)   \u001b[K\r",
      "remote: Compressing objects:  20% (33/164)   \u001b[K\r",
      "remote: Compressing objects:  21% (35/164)   \u001b[K\r",
      "remote: Compressing objects:  22% (37/164)   \u001b[K\r",
      "remote: Compressing objects:  23% (38/164)   \u001b[K\r",
      "remote: Compressing objects:  24% (40/164)   \u001b[K\r",
      "remote: Compressing objects:  25% (41/164)   \u001b[K\r",
      "remote: Compressing objects:  26% (43/164)   \u001b[K\r",
      "remote: Compressing objects:  27% (45/164)   \u001b[K\r",
      "remote: Compressing objects:  28% (46/164)   \u001b[K\r",
      "remote: Compressing objects:  29% (48/164)   \u001b[K\r",
      "remote: Compressing objects:  30% (50/164)   \u001b[K\r",
      "remote: Compressing objects:  31% (51/164)   \u001b[K\r",
      "remote: Compressing objects:  32% (53/164)   \u001b[K\r",
      "remote: Compressing objects:  33% (55/164)   \u001b[K\r",
      "remote: Compressing objects:  34% (56/164)   \u001b[K\r",
      "remote: Compressing objects:  35% (58/164)   \u001b[K\r",
      "remote: Compressing objects:  36% (60/164)   \u001b[K\r",
      "remote: Compressing objects:  37% (61/164)   \u001b[K\r",
      "remote: Compressing objects:  38% (63/164)   \u001b[K\r",
      "remote: Compressing objects:  39% (64/164)   \u001b[K\r",
      "remote: Compressing objects:  40% (66/164)   \u001b[K\r",
      "remote: Compressing objects:  41% (68/164)   \u001b[K\r",
      "remote: Compressing objects:  42% (69/164)   \u001b[K\r",
      "remote: Compressing objects:  43% (71/164)   \u001b[K\r",
      "remote: Compressing objects:  44% (73/164)   \u001b[K\r",
      "remote: Compressing objects:  45% (74/164)   \u001b[K\r",
      "remote: Compressing objects:  46% (76/164)   \u001b[K\r",
      "remote: Compressing objects:  47% (78/164)   \u001b[K\r",
      "remote: Compressing objects:  48% (79/164)   \u001b[K\r",
      "remote: Compressing objects:  49% (81/164)   \u001b[K\r",
      "remote: Compressing objects:  50% (82/164)   \u001b[K\r",
      "remote: Compressing objects:  51% (84/164)   \u001b[K\r",
      "remote: Compressing objects:  52% (86/164)   \u001b[K\r",
      "remote: Compressing objects:  53% (87/164)   \u001b[K\r",
      "remote: Compressing objects:  54% (89/164)   \u001b[K\r",
      "remote: Compressing objects:  55% (91/164)   \u001b[K\r",
      "remote: Compressing objects:  56% (92/164)   \u001b[K\r",
      "remote: Compressing objects:  57% (94/164)   \u001b[K\r",
      "remote: Compressing objects:  58% (96/164)   \u001b[K\r",
      "remote: Compressing objects:  59% (97/164)   \u001b[K\r",
      "remote: Compressing objects:  60% (99/164)   \u001b[K\r",
      "remote: Compressing objects:  61% (101/164)   \u001b[K\r",
      "remote: Compressing objects:  62% (102/164)   \u001b[K\r",
      "remote: Compressing objects:  63% (104/164)   \u001b[K\r",
      "remote: Compressing objects:  64% (105/164)   \u001b[K\r",
      "remote: Compressing objects:  65% (107/164)   \u001b[K\r",
      "remote: Compressing objects:  66% (109/164)   \u001b[K\r",
      "remote: Compressing objects:  67% (110/164)   \u001b[K\r",
      "remote: Compressing objects:  68% (112/164)   \u001b[K\r",
      "remote: Compressing objects:  69% (114/164)   \u001b[K\r",
      "remote: Compressing objects:  70% (115/164)   \u001b[K\r",
      "remote: Compressing objects:  71% (117/164)   \u001b[K\r",
      "remote: Compressing objects:  72% (119/164)   \u001b[K\r",
      "remote: Compressing objects:  73% (120/164)   \u001b[K\r",
      "remote: Compressing objects:  74% (122/164)   \u001b[K\r",
      "remote: Compressing objects:  75% (123/164)   \u001b[K\r",
      "remote: Compressing objects:  76% (125/164)   \u001b[K\r",
      "remote: Compressing objects:  77% (127/164)   \u001b[K\r",
      "remote: Compressing objects:  78% (128/164)   \u001b[K\r",
      "remote: Compressing objects:  79% (130/164)   \u001b[K\r",
      "remote: Compressing objects:  80% (132/164)   \u001b[K\r",
      "remote: Compressing objects:  81% (133/164)   \u001b[K\r",
      "remote: Compressing objects:  82% (135/164)   \u001b[K\r",
      "remote: Compressing objects:  83% (137/164)   \u001b[K\r",
      "remote: Compressing objects:  84% (138/164)   \u001b[K\r",
      "remote: Compressing objects:  85% (140/164)   \u001b[K\r",
      "remote: Compressing objects:  86% (142/164)   \u001b[K\r",
      "remote: Compressing objects:  87% (143/164)   \u001b[K\r",
      "remote: Compressing objects:  88% (145/164)   \u001b[K\r",
      "remote: Compressing objects:  89% (146/164)   \u001b[K\r",
      "remote: Compressing objects:  90% (148/164)   \u001b[K\r",
      "remote: Compressing objects:  91% (150/164)   \u001b[K\r",
      "remote: Compressing objects:  92% (151/164)   \u001b[K\r",
      "remote: Compressing objects:  93% (153/164)   \u001b[K\r",
      "remote: Compressing objects:  94% (155/164)   \u001b[K\r",
      "remote: Compressing objects:  95% (156/164)   \u001b[K\r",
      "remote: Compressing objects:  96% (158/164)   \u001b[K\r",
      "remote: Compressing objects:  97% (160/164)   \u001b[K\r",
      "remote: Compressing objects:  98% (161/164)   \u001b[K\r",
      "remote: Compressing objects:  99% (163/164)   \u001b[K\r",
      "remote: Compressing objects: 100% (164/164)   \u001b[K\r",
      "remote: Compressing objects: 100% (164/164), done.\u001b[K\r\n",
      "Receiving objects:   0% (1/336)   \r",
      "Receiving objects:   1% (4/336)   \r",
      "Receiving objects:   2% (7/336)   \r",
      "Receiving objects:   3% (11/336)   \r",
      "Receiving objects:   4% (14/336)   \r",
      "Receiving objects:   5% (17/336)   \r",
      "Receiving objects:   6% (21/336)   \r",
      "Receiving objects:   7% (24/336)   \r",
      "Receiving objects:   8% (27/336)   \r",
      "Receiving objects:   9% (31/336)   \r",
      "Receiving objects:  10% (34/336)   \r",
      "Receiving objects:  11% (37/336)   \r",
      "Receiving objects:  12% (41/336)   \r",
      "Receiving objects:  13% (44/336)   \r",
      "Receiving objects:  14% (48/336)   \r",
      "Receiving objects:  15% (51/336)   \r",
      "Receiving objects:  16% (54/336)   \r",
      "Receiving objects:  17% (58/336)   \r",
      "Receiving objects:  18% (61/336)   \r",
      "Receiving objects:  19% (64/336)   \r",
      "Receiving objects:  20% (68/336)   \r",
      "Receiving objects:  21% (71/336)   \r",
      "Receiving objects:  22% (74/336)   \r",
      "Receiving objects:  23% (78/336)   \r",
      "Receiving objects:  24% (81/336)   \r",
      "Receiving objects:  25% (84/336)   \r",
      "Receiving objects:  26% (88/336)   \r",
      "Receiving objects:  27% (91/336)   \r",
      "Receiving objects:  28% (95/336)   \r",
      "Receiving objects:  29% (98/336)   \r",
      "Receiving objects:  30% (101/336)   \r",
      "Receiving objects:  31% (105/336)   \r",
      "Receiving objects:  32% (108/336)   \r",
      "Receiving objects:  33% (111/336)   \r",
      "Receiving objects:  34% (115/336)   \r",
      "Receiving objects:  35% (118/336)   \r",
      "Receiving objects:  36% (121/336)   \r",
      "Receiving objects:  37% (125/336)   \r",
      "Receiving objects:  38% (128/336)   \r",
      "Receiving objects:  39% (132/336)   \r",
      "Receiving objects:  40% (135/336)   \r",
      "Receiving objects:  41% (138/336)   \r",
      "Receiving objects:  42% (142/336)   \r",
      "Receiving objects:  43% (145/336)   \r",
      "Receiving objects:  44% (148/336)   \r",
      "Receiving objects:  45% (152/336)   \r",
      "Receiving objects:  46% (155/336)   \r",
      "Receiving objects:  47% (158/336)   \r",
      "Receiving objects:  48% (162/336)   \r",
      "Receiving objects:  49% (165/336)   \r",
      "Receiving objects:  50% (168/336)   \r",
      "Receiving objects:  51% (172/336)   \r",
      "Receiving objects:  52% (175/336)   \r",
      "Receiving objects:  53% (179/336)   \r",
      "Receiving objects:  54% (182/336)   \r",
      "Receiving objects:  55% (185/336)   \r",
      "Receiving objects:  56% (189/336)   \r",
      "Receiving objects:  57% (192/336)   \r",
      "Receiving objects:  58% (195/336)   \r",
      "Receiving objects:  59% (199/336)   \r",
      "Receiving objects:  60% (202/336)   \r",
      "Receiving objects:  61% (205/336)   \r",
      "Receiving objects:  62% (209/336)   \r",
      "Receiving objects:  63% (212/336)   \r",
      "Receiving objects:  64% (216/336)   \r",
      "Receiving objects:  65% (219/336)   \r",
      "Receiving objects:  66% (222/336)   \r",
      "Receiving objects:  67% (226/336)   \r",
      "Receiving objects:  68% (229/336)   \r",
      "Receiving objects:  69% (232/336)   \r",
      "Receiving objects:  70% (236/336)   \r",
      "Receiving objects:  71% (239/336)   \r",
      "Receiving objects:  72% (242/336)   \r",
      "Receiving objects:  73% (246/336)   \r",
      "Receiving objects:  74% (249/336)   \r",
      "Receiving objects:  75% (252/336)   \r",
      "Receiving objects:  76% (256/336)   \r",
      "Receiving objects:  77% (259/336)   \r",
      "Receiving objects:  78% (263/336)   \r",
      "Receiving objects:  79% (266/336)   \r",
      "Receiving objects:  80% (269/336)   \r",
      "Receiving objects:  81% (273/336)   \r",
      "Receiving objects:  82% (276/336)   \r",
      "Receiving objects:  83% (279/336)   \r",
      "Receiving objects:  84% (283/336)   \r",
      "Receiving objects:  85% (286/336)   \r",
      "Receiving objects:  86% (289/336)   \r",
      "Receiving objects:  87% (293/336)   \r",
      "Receiving objects:  88% (296/336)   \r",
      "Receiving objects:  89% (300/336)   \r",
      "Receiving objects:  90% (303/336)   \r",
      "remote: Total 336 (delta 204), reused 278 (delta 167)\u001b[K\r\n",
      "Receiving objects:  91% (306/336)   \r",
      "Receiving objects:  92% (310/336)   \r",
      "Receiving objects:  93% (313/336)   \r",
      "Receiving objects:  94% (316/336)   \r",
      "Receiving objects:  95% (320/336)   \r",
      "Receiving objects:  96% (323/336)   \r",
      "Receiving objects:  97% (326/336)   \r",
      "Receiving objects:  98% (330/336)   \r",
      "Receiving objects:  99% (333/336)   \r",
      "Receiving objects: 100% (336/336)   \r",
      "Receiving objects: 100% (336/336), 403.80 KiB | 0 bytes/s, done.\r\n",
      "Resolving deltas:   0% (0/204)   \r",
      "Resolving deltas:   9% (20/204)   \r",
      "Resolving deltas:  10% (21/204)   \r",
      "Resolving deltas:  17% (35/204)   \r",
      "Resolving deltas:  22% (45/204)   \r",
      "Resolving deltas:  25% (51/204)   \r",
      "Resolving deltas:  31% (64/204)   \r",
      "Resolving deltas:  40% (82/204)   \r",
      "Resolving deltas:  44% (91/204)   \r",
      "Resolving deltas:  46% (94/204)   \r",
      "Resolving deltas:  47% (97/204)   \r",
      "Resolving deltas:  49% (101/204)   \r",
      "Resolving deltas:  50% (103/204)   \r",
      "Resolving deltas:  53% (109/204)   \r",
      "Resolving deltas:  54% (112/204)   \r",
      "Resolving deltas:  55% (114/204)   \r",
      "Resolving deltas:  56% (116/204)   \r",
      "Resolving deltas:  57% (118/204)   \r",
      "Resolving deltas:  58% (120/204)   \r",
      "Resolving deltas:  59% (122/204)   \r",
      "Resolving deltas:  60% (124/204)   \r",
      "Resolving deltas:  61% (125/204)   \r",
      "Resolving deltas:  66% (135/204)   \r",
      "Resolving deltas:  68% (139/204)   \r",
      "Resolving deltas:  73% (150/204)   \r",
      "Resolving deltas:  74% (151/204)   \r",
      "Resolving deltas:  75% (153/204)   \r",
      "Resolving deltas:  79% (163/204)   \r",
      "Resolving deltas:  81% (167/204)   \r",
      "Resolving deltas:  82% (168/204)   \r",
      "Resolving deltas:  83% (170/204)   \r",
      "Resolving deltas:  84% (172/204)   \r",
      "Resolving deltas:  88% (180/204)   \r",
      "Resolving deltas:  91% (187/204)   \r",
      "Resolving deltas:  92% (188/204)   \r",
      "Resolving deltas: 100% (204/204)   \r",
      "Resolving deltas: 100% (204/204), done.\r\n",
      "Checking connectivity... done.\r\n"
     ]
    }
   ],
   "source": [
    "system(\"git clone https://gitlab.cern.ch/yixin/atlas-outreach-cpp-framework-13tev.git\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Get into the folder which contains the analysis code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "chdir(\"atlas-outreach-cpp-framework-13tev/Beta/\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print your current path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print your current time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Aug 12 20:06:16 CEST 2019\r\n"
     ]
    }
   ],
   "source": [
    "system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Download the 13Tev dataset for Hyy analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system(\"wget -c http://opendata.atlas.cern/release/samples/2019/GamGam/ATLAS-open-data-13TeV-2019-GamGam.zip\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print current system time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Unzip the dataset you download"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system('unzip ATLAS-open-data-13TeV-2019-GamGam.zip');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print current system time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Remove the zip file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system('rm -rf ATLAS-open-data-13TeV-2019-GamGam.zip');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Print current system time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "//system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Change your current path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "//chdir(\"../atlas-outreach-cpp-framework-13tev\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Begin analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Creat the output folder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta\r\n"
     ]
    }
   ],
   "source": [
    "system(\"mkdir -p Analysis/HyyAnalysis/Output_HyyAnalysis\");\n",
    "system(\"rm -rf Analysis/HyyAnalysis/Output_HyyAnalysis/*\");\n",
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Change to the analysis code path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "chdir(\"Analysis/HyyAnalysis/\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta/Analysis/HyyAnalysis\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List the content of this folder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 44K\r\n",
      "-rwxr-xr-x 1 summerstudent users  347 Aug 12 20:06 run.sh\r\n",
      "-rwxr-xr-x 1 summerstudent users  271 Aug 12 20:06 run0.sh\r\n",
      "-rw-r--r-- 1 summerstudent users 1.4K Aug 12 20:06 main_HyyAnalysis.C\r\n",
      "-rw-r--r-- 1 summerstudent users 1.5K Aug 12 20:06 HyyAnalysisHistograms.h\r\n",
      "-rw-r--r-- 1 summerstudent users  16K Aug 12 20:06 HyyAnalysis.h\r\n",
      "-rw-r--r-- 1 summerstudent users 5.9K Aug 12 20:06 HyyAnalysis.C\r\n",
      "lrwxrwxrwx 1 summerstudent users   11 Aug 12 20:06 clean.sh -> ../clean.sh\r\n",
      "drwxr-xr-x 2 summerstudent users 4.0K Aug 12 20:06 Output_HyyAnalysis\r\n"
     ]
    }
   ],
   "source": [
    "system(\"ls -lhrt\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now it's time to RUN!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "starting ROOT\r\n",
      "Starting analysis with process option: data \r\n",
      "analyzed an total  6.84646e+06 events\r\n",
      "after trigger      1 or 6.84646e+06 events\r\n",
      "after 2 good tight 0.125884 or 6.84646e+06 events\r\n",
      "after 2 isolated   0.370642 or 861857 events\r\n",
      "after pT cuts      0.885997 or 319440 events\r\n",
      "after window  cut  0.236073 or 283023 events\r\n",
      "wrote histograms to file Output_HyyAnalysis/data.root\r\n",
      "Starting analysis with process option: ggH125_gamgam \r\n",
      "analyzed an total  1.05471e+06 events\r\n",
      "after trigger      1 or 1.05471e+06 events\r\n",
      "after 2 good tight 0.793151 or 1.05471e+06 events\r\n",
      "after 2 isolated   0.882695 or 836547 events\r\n",
      "after pT cuts      0.9257 or 738416 events\r\n",
      "after window  cut  0.999769 or 683552 events\r\n",
      "wrote histograms to file Output_HyyAnalysis/ggH125_gamgam.root\r\n",
      "end of ROOT execution\r\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Info in <TUnixSystem::ACLiC>: creating shared library /home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta/Analysis/HyyAnalysis/./HyyAnalysis_C.so\r\n",
      "Info in <ACLiC>: unmodified script has already been compiled and loaded\r\n"
     ]
    }
   ],
   "source": [
    "system(\"./run0.sh 0\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Aug 12 20:10:29 CEST 2019\r\n"
     ]
    }
   ],
   "source": [
    "system(\"date\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Plot the result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "chdir(\"../../Plotting_Hyy/\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta/Plotting_Hyy\r\n"
     ]
    }
   ],
   "source": [
    "system(\"pwd\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Info in <TUnixSystem::ACLiC>: creating shared library /home/student/demos-framework-software-notebooks/cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta/Plotting_Hyy/./Plotting_cxx.so\r\n",
      "Info in <TCanvas::Print>: png file histograms/hist_mYY_incl.png has been created\r\n",
      "Warning in <TFile::Append>: Replacing existing TH1: copy_fit1 (Potential memory leak).\r\n",
      "Info in <TCanvas::Print>: png file histograms/hist_mYY_win.png has been created\r\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start plotting\r\n",
      "\r\n",
      " ---------------------DISCLAIMER--------------------- \r\n",
      "\r\n",
      "This Software is intended for educational use only!\r\n",
      "Under no circumstances does it qualify to reproduce actual ATLAS analysis results or produce publishable results! \r\n",
      "\r\n",
      " ---------------------------------------------------- \r\n",
      "\r\n",
      "data 1 1 1\r\n",
      "ggH125_gamgam 0.102 55922617.6297 1\r\n",
      "\r\n",
      " Reading files from: ../Analysis/HyyAnalysis/Output_HyyAnalysis \r\n",
      " \r\n",
      "=====processing HyyAnalysis=====\r\n",
      "Reading file: ../Analysis/HyyAnalysis/Output_HyyAnalysis/data.root\r\n",
      "reading histogram: hist_mYY_win\r\n",
      "reading histogram: hist_mYY_incl\r\n",
      "Reading file: ../Analysis/HyyAnalysis/Output_HyyAnalysis/ggH125_gamgam.root\r\n",
      "reading histogram: hist_mYY_win\r\n",
      "reading histogram: hist_mYY_incl\r\n",
      " SF is: 0\r\n",
      "Scaling histogram: hist_mYY_incl\r\n",
      "Scaling histogram: hist_mYY_win\r\n",
      "Plotting histogram: hist_mYY_incl\r\n",
      "0\r\n",
      " FCN=12.9855 FROM HESSE     STATUS=NOT POSDEF     23 CALLS         158 TOTAL\r\n",
      "                     EDM=3.1212e-12    STRATEGY= 1      ERR MATRIX NOT POS-DEF\r\n",
      "  EXT PARAMETER                APPROXIMATE        STEP         FIRST   \r\n",
      "  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE \r\n",
      "   1  p0           9.62489e+04   8.08654e+01   2.29475e-02   8.23653e-09\r\n",
      "   2  p1          -1.80060e+03   8.73237e-01   4.29296e-04  -1.52820e-06\r\n",
      "   3  p2           1.16338e+01   6.01641e-03   2.77371e-06  -1.64026e-04\r\n",
      "   4  p3          -2.56286e-02   2.99507e-05   6.11034e-09   2.10257e-02\r\n",
      "   5  p4           9.17000e+01     fixed    \r\n",
      "   6  p5           1.25000e+02     fixed    \r\n",
      "   7  p6           2.40000e+00     fixed    \r\n",
      "Chi2/NDF: 0.618358\r\n",
      "Plotting histogram: hist_mYY_win\r\n",
      "0\r\n",
      " FCN=55.6085 FROM HESSE     STATUS=NOT POSDEF     23 CALLS         160 TOTAL\r\n",
      "                     EDM=5.44695e-12    STRATEGY= 1      ERR MATRIX NOT POS-DEF\r\n",
      "  EXT PARAMETER                APPROXIMATE        STEP         FIRST   \r\n",
      "  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE \r\n",
      "   1  p0           4.78196e+04   3.67180e+01   1.14011e-02   2.74437e-08\r\n",
      "   2  p1          -9.10477e+02   3.96466e-01   2.17075e-04  -3.80852e-06\r\n",
      "   3  p2           5.97288e+00   2.73084e-03   1.42405e-06  -3.63575e-04\r\n",
      "   4  p3          -1.33302e-02   1.35902e-05   3.17816e-09   8.00203e-02\r\n",
      "   5  p4           9.17000e+01     fixed    \r\n",
      "   6  p5           1.25000e+02     fixed    \r\n",
      "   7  p6           2.40000e+00     fixed    \r\n",
      "Chi2/NDF: 1.09036\r\n"
     ]
    }
   ],
   "source": [
    "system(\"./plotting.sh\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 80K\r\n",
      "-rw-r--r-- 1 summerstudent users 25K Aug 12 20:06 hist_mYY_pt.png\r\n",
      "-rw-r--r-- 1 summerstudent users 23K Aug 12 20:10 hist_mYY_incl.png\r\n",
      "-rw-r--r-- 1 summerstudent users 26K Aug 12 20:10 hist_mYY_win.png\r\n"
     ]
    }
   ],
   "source": [
    "system(\"ls -lhrt histograms/\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<CENTER><img src=\"cpp-13tev/atlas-outreach-cpp-framework-13tev/Beta/Plotting_Hyy/histograms/hist_mYY_incl.png\"></CENTER>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Aug 12 20:10:40 CEST 2019\r\n",
      "Finished in 9 min 49 s \r\n"
     ]
    }
   ],
   "source": [
    "system(\"date\");\n",
    "clock_t endTime = clock(); \n",
    "double time_taken = (double) (endTime-startTime) / CLOCKS_PER_SEC * 1000.0; // in seconds \n",
    "cout << \"Finished in \" << (int)(time_taken / 60) << \" min \" << (int)time_taken % (int)60 << \" s \" << endl;   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ROOT Prompt",
   "language": "c++",
   "name": "root"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
